Blood pressure and pulse readings taken morning and evening with an Omron blood pressure cuff. Also collect binary factors: work, cycling and alcohol. Attempt to correlate blood pressure and pulse with factors.

Readings start on Feb 8, 2019. Alcohol was abstained from between Jan 1, 2019 and Apr 18, 2019, a period of 109 days.

Read and preprocess latest blood-pressure file. Join with a file containing factors (work, cycling and alcohol).

library(lubridate)
b <- read.csv(file="bp.csv", header=TRUE, sep=",")
f <- read.csv(file="factors.csv", header=TRUE, sep=",")
bp <- merge(b, f, all.x = TRUE)
bp[is.na(bp)] <- 0
bp$datetime <- as_datetime(paste(bp$date, bp$time))
mp <- c(min(bp$dia), max(bp$sys))
cdia <- rgb(0,0,1,1/4)
csys <- rgb(1,0,0,1/4)
cpul <- rgb(0,1,0,1/4)

A function to plot blood pressure histograms:

plot.blood.pressure <- function(bp, title) {
  hsys <- hist(bp$sys, plot=F)
  hdia <- hist(bp$dia, plot=F)
  mc <- c(0, max(c(hsys$counts, hdia$counts)))
  plot(hdia, col=cdia, xlim=mp, ylim=mc, main = paste(title, " (", as.Date(min(bp$datetime)), " to ", as.Date(max(bp$datetime)), ")", sep=""), xlab = "mmHg")
  plot(hsys, col=csys, xlim=mp, ylim=mc, add=T)
  mdia <- mean(bp$dia)
  msys <- mean(bp$sys)
  abline(v=c(msys, mdia), col=c("red","blue"))
  legend("topright", bty="n", legend=c(paste("sys: ", format(msys, digits=2)), paste("dia: ", format(mdia, digits=2))))
}

Histograms

Overall

Plot systolic and diastolic pressures for all data points.

plot.blood.pressure(bp, "Overall")

Recent

Over the last four weeks:

recent <- max(bp$datetime) - bp$datetime < 28*24*3600
plot.blood.pressure(bp[recent,], "Recently")

Morning

am <- hour(bp$datetime) < 12
plot.blood.pressure(bp[am,], "Morning")

Evening

pm <- hour(bp$datetime) >= 12
plot.blood.pressure(bp[pm,], "Evening")

Work days

plot.blood.pressure(bp[bp$work == 1,], "Work")

Days Off

plot.blood.pressure(bp[bp$work == 0,], "Days Off")

Other Views

Over Time

Systolic and diastolic blood pressure over time.

movavg <- function(x, n=14){
  filter(x,rep(1/n,n), sides=2)
}
plot.dates <- function(bp, var, col, yl="mmHg", ma=T) {
  cs <- c("green", "blue")
  dates <- bp$datetime
  points <- bp[,var]
  am <- hour(bp$datetime) < 12
  pm <- !am
  plot(dates[am], points[am], xlab="Date", ylab=yl, main=var, col=cs[1])
  abline(v=dates[bp$work == 1], col="lightgray")
  abline(v=dates[pm & (bp$alcohol == 1)], col="red")
  abline(v=dates[pm & (bp$cycle == 1)], col="green")
  if (ma) {
    lines(dates[am], movavg(points[am]), col=cs[1])
    lines(dates[pm], movavg(points[pm]), col=cs[2])
  }
  sd <- lm(points~dates)
  abline(sd, col=col)
  points(dates[am], points[am], col=cs[1])
  points(dates[pm], points[pm], col=cs[2])
  legend("bottomright", bty="n", legend=paste("r^2: ", format(summary(sd)$r.squared, digits=2)))
  legend("bottomleft", bty="n", legend=c("am", "pm"), text.col = cs, pt.bg=cs)
}
plot.dates(bp, "sys", "red")

plot.dates(bp, "dia", "blue")

Systolic vs Diastolic Pressure

plot(bp$dia, bp$sys, xlab = "Diastolic", ylab="Systolic")
msd <- lm(bp$sys~bp$dia)
abline(msd)
legend("bottomright", bty="n", legend=paste("r^2: ", format(summary(msd)$r.squared, digits=2)))

Pulse

plot.pulse <- function(bp, c, title) {
  hpul <- hist(bp$pulse, plot=F)
  plot(hpul, col=c, main = title, xlab = "bpm")
  m <- mean(bp$pulse)
  abline(v=m, col=c)
  legend("topright", bty="n", legend=paste("av: ", format(m, digits=2)))
}
plot.pulse(bp, cpul, "Overall")

Morning

Working days and days off.

plot.pulse(bp[am & bp$work==1 & bp$alcohol==0,], cpul, "Morning (work)")

plot.pulse(bp[am & bp$work==0 & bp$alcohol==0,], cpul, "Morning (off)")

Evening

Evening of working days and days off.

plot.pulse(bp[am & bp$work==1 & bp$alcohol==0,], cpul, "Evening (work)")

plot.pulse(bp[pm & bp$work==0 & bp$alcohol==0,], cpul, "Evening (off)")

Over Time

plot.dates(bp, "pulse", "green", "bpm")

Alcohol-free

The initial period without alcohol (between Jan 1 and Apr 18, 2019). This coincided with work.

plot.blood.pressure(bp[bp$datetime < "2019-04-18",], "Alcohol-free")

plot.dates(bp[bp$datetime < "2019-04-18",], "sys", "red")

plot.dates(bp[bp$datetime < "2019-04-18",], "dia", "blue")

plot.dates(bp[bp$datetime < "2019-04-18",], "pulse", "green", "bpm")

Alcohol

Subsequent period with alcohol at weekends. This coincided with a period of strenuous daily exercise (cycling).

plot.blood.pressure(bp[bp$datetime >= "2019-04-18",], "Alcohol")

plot.dates(bp[bp$datetime >= "2019-04-18",], "sys", "red")

plot.dates(bp[bp$datetime >= "2019-04-18",], "dia", "blue")

plot.dates(bp[bp$datetime >= "2019-04-18",], "pulse", "green", "bpm")